package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Control;
import com.ruoyi.system.service.IControlService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 布控信息Controller
 * 
 * @author zbb
 * @date 2023-02-13
 */
@Controller
@RequestMapping("/control/control")
public class ControlController extends BaseController
{
    private String prefix = "control/control";

    private String prefix1 = "control/localSq";
    private String prefix2 = "control/localSh";
    private String prefix3 = "control/localCx";
    private String prefix4 = "control/shiSq";
    private String prefix5 = "control/shiSh";

    private String prefix6 = "control/shiSsh";
    private String prefix7 = "control/shiCx";


    @Autowired
    private IControlService controlService;

    @RequiresPermissions("control:control:view")
    @GetMapping()
    public String control()
    {
        return prefix + "/control";
    }
    /**
     * 新增布控信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 修改布控信息
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/edit/{controlId}")
    public String edit(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix + "/edit";
    }

    /**
     * 本地申请管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/localSq")
    public String localSq()
    {
        return prefix1+"/localSq";
    }

    /**
     * 本地申请新增页面
     */
    @GetMapping("/addlocalSq")
    public String addlocalSq()
    {
        return prefix1 + "/add";
    }

    /**
     * 本地申请修改页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editlocalSq/{controlId}")
    public String editlocalSq(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix1 + "/edit";
    }

    /**
     * 本地审核管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/localSh")
    public String localSh()
    {
        return prefix2+"/localSh";
    }

    /**
     * 本地审核新增页面
     */
    @GetMapping("/addlocalSh")
    public String addlocalSh()
    {
        return prefix2 + "/add";
    }

    /**
     * 本地审核修改页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editlocalSh/{controlId}")
    public String editlocalSh(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix2 + "/edit";
    }

    /**
     * 本地查询管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/localCx")
    public String localCx()
    {
        return prefix3+"/localCx";
    }

    /**
     * 本地查询新增页面
     */
    @GetMapping("/addlocalCx")
    public String addlocalCx()
    {
        return prefix3 + "/add";
    }

    /**
     * 本地查询修改页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editlocalCx/{controlId}")
    public String editlocalCx(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix3 + "/edit";
    }

    /**
     * 跨市申请管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/shiSq")
    public String shiSq()
    {
        return prefix4+"/shiSq";
    }

    /**
     * 跨市申请新增页面
     */
    @GetMapping("/addshiSq")
    public String addshiSq()
    {
        return prefix4 + "/add";
    }

    /**
     * 跨市申请修改页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editshiSq/{controlId}")
    public String editshiSq(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix4 + "/edit";
    }

    /**
     * 跨市市级审核管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/shiSh")
    public String shiSh()
    {
        return prefix5+"/shiSh";
    }

    /**
     * 跨市市级审核新增页面
     */
    @GetMapping("/addshiSh")
    public String addshiSh()
    {
        return prefix5 + "/add";
    }

    /**
     * 跨市市级审核修改布控信息页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editshiSh/{controlId}")
    public String editshiSh(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix5 + "/edit";
    }

    /**
     * 跨市省级审核管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/shiSsh")
    public String shiSsh()
    {
        return prefix6+"/shiSsh";
    }

    /**
     * 跨市省级审核新增布控信息页面
     */
    @GetMapping("/addshiSsh")
    public String addshiSsh()
    {
        return prefix6 + "/add";
    }

    /**
     * 跨市省级审核修改布控信息页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editshiSsh/{controlId}")
    public String editshiSsh(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix6 + "/edit";
    }

    /**
     * 跨市查询管理页面
     * @return
     */
    @RequiresPermissions("control:control:view")
    @GetMapping("/shiCx")
    public String shiCx()
    {
        return prefix7+"/shiCx";
    }

    /**
     * 跨市查询新增管理页面
     */
    @GetMapping("/addshiCx")
    public String addshiCx()
    {
        return prefix7 + "/add";
    }

    /**
     * 跨市查询修改管理页面
     */
    @RequiresPermissions("control:control:edit")
    @GetMapping("/editshiCx/{controlId}")
    public String editshiCx(@PathVariable("controlId") Long controlId, ModelMap mmap)
    {
        Control control = controlService.selectControlByControlId(controlId);
        mmap.put("control", control);
        return prefix7 + "/edit";
    }






    /**
     * 查询布控信息列表
     */
    @RequiresPermissions("control:control:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Control control)
    {
        startPage();
        List<Control> list = controlService.selectControlList(control);
        return getDataTable(list);
    }

    /**
     * 导出布控信息列表
     */
    @RequiresPermissions("control:control:export")
    @Log(title = "布控信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Control control)
    {
        List<Control> list = controlService.selectControlList(control);
        ExcelUtil<Control> util = new ExcelUtil<Control>(Control.class);
        return util.exportExcel(list, "布控信息数据");
    }

    /**
     * 新增保存布控信息
     */
    @RequiresPermissions("control:control:add")
    @Log(title = "布控信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Control control)
    {
        return toAjax(controlService.insertControl(control));
    }


    /**
     * 修改保存布控信息
     */
    @RequiresPermissions("control:control:edit")
    @Log(title = "布控信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Control control)
    {
        return toAjax(controlService.updateControl(control));
    }

    /**
     * 删除布控信息
     */
    @RequiresPermissions("control:control:remove")
    @Log(title = "布控信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(controlService.deleteControlByControlIds(ids));
    }
}
